#!/usr/bin/python3
# coding=utf-8
#
# Copyright (C) 2023-2024. Huawei Technologies Co., Ltd. All rights reserved.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# ===============================================================================

import numpy as np
import os
import torch
import torch.nn.functional as F

def gen_golden_data_simple():
    # 生成随机输入数据（范围设为-10到10），使用float32
    input_data = np.random.uniform(low=-10.0, high=10.0, size=(8, 2048)).astype(np.float32)
    
    # 使用PyTorch的softmin函数，输入输出都使用float32
    input_tensor = torch.from_numpy(input_data)  # 已经是float32，无需转换
    golden_tensor = F.softmin(input_tensor, dim=1)
    golden = golden_tensor.numpy().astype(np.float32)  # 保持float32
    
    # 保存输入和输出（float32格式）
    os.makedirs("input", exist_ok=True)
    input_data.tofile("input/input_x.bin")
    
    os.makedirs("output", exist_ok=True)
    golden.tofile("output/golden.bin")

if __name__ == "__main__":
    gen_golden_data_simple()